#include "../include/Keyboard_Manager.h"

Keyboard_Manager::Keyboard_Manager(Jeu* jeu)
{
    m_App = jeu->GetApp();
}

Keyboard_Manager::~Keyboard_Manager()
{
    //dtor
}

bool Keyboard_Manager::Check_Pressed(sf::Key::Code key)
{
    while (m_App->GetEvent(event))
        {
            if (event.Type == sf::Event::Closed)
                m_App->Close();
            if (event.Key.Code == key)
            return true;
        }
        return false;
}


bool Keyboard_Manager::Check_Pressed()
{
    while (m_App->GetEvent(event))
        {
            switch (event.Type)
            {
                 case sf::Event::Closed :
                 m_App->Close();
                 break;

                 default :
                 return true;
                 break;
            }

        }
        return false;
}


bool Keyboard_Manager::Check_Input(sf::Key::Code key)
{
    const sf::Input& Input = m_App->GetInput();

    if (Input.IsKeyDown(key))
    return true;

    return false;
}

sf::Mouse::Button Keyboard_Manager::MouseClick()
{
    if (m_App->GetEvent(event))
    {
        if (event.MouseButton.Button == sf::Mouse::Left)
        return sf::Mouse::Left;

        if (event.MouseButton.Button == sf::Mouse::Right)
        return sf::Mouse::Right;

        if (event.MouseButton.Button == sf::Mouse::Middle)
        return sf::Mouse::Middle;
    }
    return sf::Mouse::ButtonCount;
}

int Keyboard_Manager::MouseX()
{
    if (m_App->GetEvent(event) && event.MouseMoved)
    {
        return event.MouseButton.X;
    }
    return 3000;
}

int Keyboard_Manager::MouseY()
{
    if (m_App->GetEvent(event) && event.MouseMoved)
    {
        return event.MouseButton.Y;
    }
    return 3000;
}

